package com.yuanzhy.sca.service.blog.controller;

import com.yuanzhy.sca.service.blog.feign.UserFeignClientDemo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * Created by yuanzhy on 2018/5/12.
 */
@RestController
public class DemoFeignConsumeController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private UserFeignClientDemo userClient;

    @GetMapping("/testRemoteFeign")
    public String ListUsers(HttpServletRequest request) {
        Enumeration<String> e = request.getHeaderNames();
        while (e.hasMoreElements()) {
            String name = e.nextElement();
            logger.info("--header--{}: {}", name, request.getHeader(name));
        }
        return "使用feign形式调用远程user服务：" + this.userClient.test();
    }
}
